<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 14587
  Date: 2020/11/13
  Time: 16:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>上传博客</title>
    <%@include file="../common/head.jsp"%>
    <script type="text/javascript" src="${pageContext.request.contextPath}/showdown-1.9.1/dist/showdown.min.js"></script>
</head>
<body class="pic-bg">
<div class="container-fluid height:750px;overflow:auto">
    <div class="row-fluid clearfix">
        <div class="col-md-12">
            <div class="page-header">
                <h1 style="color: white">
                    上传博客
                </h1>
            </div>
        </div>
        <div class="col-md-10"></div>
        <div class="col-md-2">
                <div>
                    <h1>
                        <small>
                            <a href="${pageContext.request.contextPath}/page/showPage" style="color:white">返回首页</a>
                        </small>
                    </h1>
                </div>
        </div>
    </div>
    <form action="${pageContext.request.contextPath}/blog/addUpdateBlog" method="post">
        <c:if test="${updateBlogInfo!=null}"><input class="hidden" name="blogId" value="${updateBlogInfo.blogId}"></c:if>
        <div class="row-fluid col-md-12">
            <div class="col-md-4">
                <label style="color: white"><h4>博客标题：</h4></label><%--添加了required表示表单的内容必须都填写完了才能提交--%>
                <input type="text" name="title" autocomplete="off" class="form-control" value="${updateBlogInfo.title}" required>
            </div>
            <div class="col-md-8"></div>
        </div>
        <div class="row-fluid col-md-12">
            <div class="form-group col-md-6" style="overflow:auto">
                <label style="color: white"><h4>博客内容：</h4></label>
                <textarea id="oriContent"  style="height: 700px;width: 100%"  name="comment" onkeyup="convert()">${updateBlogInfo.comment}</textarea>
            </div>
            <div class="col-md-6 displayTextBg">
                <label style="color: white"><h4>页面效果：</h4></label>
                <div id="result" style="color:white;height:700px;width:100%;overflow:auto"></div>
            </div>
            <script type="text/javascript">
                function convert() {
                    var text = document.getElementById("oriContent").value;
                    var converter = new showdown.Converter();
                    var html = converter.makeHtml(text);
                    document.getElementById("result").innerHTML = html;
                }
            </script>
        </div>
        <button type="submit" class="btn btn-default text-right">添加</button>
        <%--这里返回的时候也会提交--%>
        <%--<button type="submit" href="${pageContext.request.contextPath}/blog/toBlogAdmin" class="btn btn-default text-right">返回</button>--%>
    </form>
    <div class="col-md-10"></div>
    <div class="col-md-2">
        <a href="${pageContext.request.contextPath}/blog/toBlogAdmin" style="color:white;">
            <h3>返回</h3>
        </a>
    </div>
</div>
</body>
</html>
